package employee;

import java.util.ArrayList;
import java.util.Scanner;
import static java.lang.Thread.sleep;

public class Employee {
    private String name;
    private String sex;
    private int age;
    private String employeeNo;
    private String position;
    private String sfzNum;
    private String phoneNumber;

    public Employee() {

    }

    public Employee(String name, String sex, int age, String employeeNo, String position,String sfz, String phone) {
        this.name = name;
        this.sex = sex;
        this.age = age;
        this.employeeNo = employeeNo;
        this.position = position;
        this.sfzNum = sfz;
        this.phoneNumber =phone;
    }



    public void setName(String Name) {
        this.name = name;
    }
    public String getName() {
        return name;
    }

    public void setSex(String Sex) {
        this.sex = sex;
    }
    public String getSex() {
        return sex;
    }

    public void setAge(int Age) {
        this.age = age;
    }
    public int getAge() {
        return age;
    }
    public void setPhoneNumber(String phoneNumber){
        this.phoneNumber = phoneNumber;
    }
    public String getPhoneNumber() {  return phoneNumber;   }
    public void setStudentNo(String StudentNo){
        this.employeeNo = StudentNo;
    }
    public String getStudentNo() {  return employeeNo;   }
    public void setSfzNum(String sfzNum){
        this.sfzNum = sfzNum;
    }
    public String getSfzNum() {  return sfzNum;   }
    public void setProfessional(String Professional) {  this.position = position;   }
    public String getProfessional() {   return position;    }


    public static void addStudent(ArrayList<Employee> studentsList, int Number) {
        Scanner scanner = new Scanner(System.in);
        for (int i = 1; i <= Number; i++) {
            System.out.println("开始录入第" + i + "个员工的信息");
            Employee employee = new Employee();
            System.out.print("姓名:");
            employee.setName(scanner.next());
            System.out.print("性别:");
            employee.setSex(scanner.next());
            System.out.print("年龄:");
            employee.setAge(scanner.nextInt());
            System.out.print("工号:");
            employee.setStudentNo(scanner.next());
            System.out.print("职位:");
            employee.setProfessional(scanner.next());
            System.out.print("身份证号:");
            employee.setProfessional(scanner.next());
            System.out.print("手机号:");
            employee.setProfessional(scanner.next());

            studentsList.add(employee);
        }
    }

    public static void removeStudent(ArrayList<Employee> studentsList, String StudentNo) {
        Scanner scanner = new Scanner(System.in);
        removeLoop : while (true) {
            int judge = 0;
            for (int i = 0; i < studentsList.size(); i++) {
                if (studentsList.get(i).getStudentNo().equals(StudentNo)) {
                    studentsList.remove(i);
                    System.out.println("删除成功");
                    judge = 1;
                }
            }
            if (judge == 0) {
                System.out.println("删除失败");
            }
            System.out.println("是否继续删除， 1-继续，2-结束");
            String choose = scanner.next();
            switch (choose) {
                case"1":{
                    System.out.println("继续删除");
                    System.out.println("请输入您要删除的员工信息的学号");
                    StudentNo = scanner.next();
                    break;
                }
                case"2":{
                    break removeLoop;
                }
                default:{
                    System.out.println("没有该选项");
                    break;
                }
            }
        }
    }

    public static void reSetStudent(ArrayList<Employee> studentsList, String StudentNo) {
        Scanner scanner = new Scanner(System.in);
        reSetLoop : while (true) {
            int judge = 0;
            for (int i = 0; i < studentsList.size(); i++) {
                if (studentsList.get(i).getStudentNo().equals(StudentNo)) {
                    loop : while (true) {
                        System.out.println("请输入你要修改的内容,1-名字、2-性别、3-年龄、4-工号、5-职位、6-退出该员工修改");
                        String choose = scanner.next();
                        switch (choose) {
                            case"1" : {
                                System.out.println("当前名字为" + studentsList.get(i).getName() + "，请输入修改后的名字");
                                studentsList.get(i).setName(scanner.next());
                                System.out.println("当前名字为" + studentsList.get(i).getName());
                                break;
                            }
                            case"2" : {
                                System.out.println("当前性别为" + studentsList.get(i).getSex() + "，请输入修改后的性别");
                                studentsList.get(i).setSex(scanner.next());
                                System.out.println("当前性别为" + studentsList.get(i).getSex());
                                break;
                            }
                            case"3" : {
                                System.out.println("当前年龄为" + studentsList.get(i).getAge() + "，请输入修改后的年龄");
                                studentsList.get(i).setAge(scanner.nextInt());
                                System.out.println("当前年龄为" + studentsList.get(i).getAge());
                                break;
                            }
                            case"4" : {
                                System.out.println("当前工号为" + studentsList.get(i).getStudentNo() + "，请输入修改后的工号");
                                studentsList.get(i).setStudentNo(scanner.next());
                                System.out.println("当前工号为" + studentsList.get(i).getStudentNo());
                                break;
                            }
                            case"5" : {
                                System.out.println("当前职位为" + studentsList.get(i).getName() + "，请输入修改后的职位");
                                studentsList.get(i).setProfessional(scanner.next());
                                System.out.println("当前职位为" + studentsList.get(i).getProfessional());
                                break;
                            }
                            case"6" : {
                                System.out.println("当前手机号为" + studentsList.get(i).getName() + "，请输入修改后的手机号");
                                studentsList.get(i).setProfessional(scanner.next());
                                System.out.println("当前手机号为" + studentsList.get(i).getProfessional());
                                break;
                            }
                            case"7" : {
                                System.out.println("当前身份证号为" + studentsList.get(i).getName() + "，请输入修改后的身份证号");
                                studentsList.get(i).setProfessional(scanner.next());
                                System.out.println("当前身份证号为" + studentsList.get(i).getProfessional());
                                break;
                            }
                            case"10" : {
                                break loop;
                            }
                            default : {
                                System.out.println("没有该选项");
                                break;
                            }
                        }
                    }
                    judge = 1;
                }
            }
            if (judge == 0) {
                System.out.println("修改失败，因为无法查询到该员工的信息");
            }
            System.out.println("是否继续修改员工信息， 1-继续，2-结束");
            String choose = scanner.next();
            switch (choose) {
                case"1":{
                    System.out.println("继续修改");
                    System.out.println("请输入您要修改的员工信息的学号");
                    StudentNo = scanner.next();
                    break;
                }
                case"2":{
                    break reSetLoop;
                }
                default:{
                    System.out.println("没有该选项");
                    break;
                }
            }
        }
    }

    public static void checkStudent(ArrayList<Employee> studentsList, String StudentNo) {
        Scanner scanner = new Scanner(System.in);
        CheckLoop : while (true) {
            int judge = 0;
            for (int i = 0; i < studentsList.size(); i++) {
                if (studentsList.get(i).getStudentNo().equals(StudentNo)) {
                    System.out.println("查询成功，该员工信息如下");
                    System.out.println("姓名:" + studentsList.get(i).getName() + "，性别:" + studentsList.get(i).getSex() + "，年龄:" + studentsList.get(i).getAge() + "，工号:" + studentsList.get(i).getStudentNo() + "，职位:" + studentsList.get(i).getProfessional());
                    judge = 1;
                }
            }
            if (judge == 0) {
                System.out.println("查询失败，该员工不存在");
            }
            System.out.println("是否继续查询， 1-继续，2-结束");
            String choose = scanner.next();
            switch (choose) {
                case"1":{
                    System.out.println("继续查询");
                    System.out.println("请输入您要查询的员工信息的学号");
                    StudentNo = scanner.next();
                    break;
                }
                case"2":{
                    break CheckLoop;
                }
                default:{
                    System.out.println("没有该选项");
                    break;
                }
            }
        }
    }


}

